It is common in many computer applications, particularly those which are arithmetically and logically intensive, to have one or more program loops in the instruction program. Such program loops are essentially self-contained sequences of instructions in which the last instruction in the sequence repeatedly causes the program to return to the first instruction in the sequence until a terminal condition is reached. When the terminal condition occurs, however, the last instruction in the sequence causes the program to "fall through" the program loop and continue on with the remainder of the instruction program. Program loops are an extremely useful programming tool in that they allow an instruction program to guide a computer through highly iterative computations in a relatively economical fashion.
For purposes of exposition, a typical program loop is contained in the exemplary instruction program segment shown in Table I as follows:
TABLE I ______________________________________ Instruction Actual Number Instruction Comments ______________________________________ . 41 CTR .rarw. 1000 ;CTR = counter 42 Subtract ( ) ;useful instruction 43 Multiply ( ) ;useful instruction 44 Add ( ) ;useful instruction 45 CTR .rarw. CTR-1,JumpGZ(42) ;Decrement counter, ;Test if Zero, ;if not Zero, go to 42 ;if Zero, go to 46 46 Add ( ) ;useful instruction . . ______________________________________
In this instruction program segment, the program loop consists of instructions 42-45 and is designed to perform the subtract, multiply and add operations of instructions 42-44 one thousand times in sequence before the program moves on to instruction 46. To this end instruction 41 orders the computer to load a loop counter with the value 1000 representing the number of times the program loop is to be run. Instruction 42 orders the computer to perform the desired subtract operation. Instruction 43 orders the computer to perform the desired multiply operation. Instruction 44 orders the computer to perform the desired add operation. Instruction 45 orders the computer to perform a multi-part operation: first, it orders the computer to decrement the loop counter by 1, second, it orders the computer then to test the counter for the counter's value after decrementing, and third, it orders the computer to either return the program to instruction 42 if the counter's value is not zero after the decrementing step or to let the program fall through the loop to instruction 46 if the counter's value is zero after the decrementing step. When a computer processes the instruction program segment shown in Table I, it will perform the subtract, multiply and add operations of instructions 42-44 one thousand times in sequence before it moves on to perform the operation specified in instruction 46.
For the computer to perform the subtract, multiply and add operations of instructions 42-44 one thousand times in sequence, the computer must process instruction 41 once, and instructions 42-45 one thousand times. Of the various instructions contained inside the loop, three of the instructions (42-44) specify the desired computational operations (so-called "useful" instructions) and one instruction (45) performs internal counting, testing and jumping operations (a so-called "housekeeping" instruction). To some extent, housekeeping instruction 45 does not cause the computer to do the operational work required by the iterative computation. Rather, like instruction 41, instruction 45 is in the program simply to cause the computer to run the useful instructions 42-44 in the program loop the desired number of times before the computer leaves the loop and goes on to execute instruction 46. However, unlike instruction 41 which is outside the program loop and hence is only run once, instruction 45 is within the program loop and thus runs every time the loop runs.
In a relatively long program loop (e.g. 50 instructions) not run often (e.g. only 5 times), a single housekeeping instruction inside the loop does not add materially to the computer's processing time. However, in arithmetically and logically intensive applications such as scientific work, very short program loops (e.g. 4 instructions) are quite common and they must frequently be run many times (e.g. 1000 times). In these situations, inclusion of the housekeeping instruction within the program loop can add significantly and undesirably to the computer's processing time. For example, in the instruction program segment shown in Table I, if instructions 42-45 all require equal time for the machine to execute, 25% of the machine's processing time would be tied up with running the housekeeping instruction. In this respect it must also be appreciated that the housekeeping instruction can be a relatively slow one to process, since it requires the computer to execute the multiple steps of (a) decrementing the loop counter, (b) testing the value of the loop counter after decrementing, and (c) executing a jump back or fall through operation depending on the value of the loop counter after decrementing. Also, the conditional jump portion of the housekeeping instruction requires the latter to specify the jump location which the program must go to if the counter is not zero. The conditional jump portion of the housekeeping instruction may be quite lengthy and slow to process.
For these reasons it has been appreciated that if one could shorten or eliminate the housekeeping instruction in the loop, the time needed to execute the loop can be reduced significantly. Thus many computers are built with special hardware components added to the computer to allow elimination of the housekeeping instruction from the loop. This hardware generally comprises sufficient storage and control circuitry so that the computer can execute an operation as follows: "do instructions 42, 43, 44 1000 times, then fall through to instruction 46". In such an arrangement the computer does not need to process the complex conditional jump instruction every time it passes through the loop, and thus processing time for the loop is reduced. However, this solution has the significant disadvantage that additional hardware must be built into the computer with consequent extra cost.